<%@ page language="Java" import="java.util.*,descriptor.*,java.text.SimpleDateFormat" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%
	TimetableListDescriptor tbList = (TimetableListDescriptor)request.getAttribute("tbList");
	String error1 = (String)request.getAttribute("error1");
	int day = (Integer)request.getAttribute("day");
	int month = (Integer)request.getAttribute("month");
	int year = (Integer)request.getAttribute("year");
	
	String date ="";
	if(day > 0)
	{
		date = month+"/"+day+"/"+year;
	}
%>

<html>
	<jsp:include page="StudentHeader.jsp" >
		<jsp:param name="pageTitle" value="Work Placement Management System - Student" />
	</jsp:include>
	<body>
		<jsp:include page="StudentPageHeader.jsp"></jsp:include>
		<div id="container">
			<jsp:include page="StudentMenu.jsp" ></jsp:include>
			<div id="content">
				<h3 class="posttitle">Student - Events of <%= date %></h3>
				<div class="entry">
					<%
						if(tbList != null)
						{
							int sizeList = tbList.sizeTimetableList();
							if(sizeList>0)
							{
								//TimetableListDescriptor tbList2 = tbList;
								int id = 0;
								String name1 = "";
								int day1 = 0;
								int month1 = 0;
								int year1 = 0;
								int hour1 = 0;
								int minute1 = 0;
								String recruiter = "";
								String offer = "";
								//int day2 = 0;
								//int month2 = 0;
								//int year2 = 0;
								//int hour2 = 0;
								//int minute2 = 0;
								for(int j=0; j<sizeList; j++)
								{
								//while(sizeList>0)
								//{
									
									//TimetableDescriptor tb = tbList2.getTimetableDescriptors().elementAt(j);
									id = tbList.getTimetableDescriptors().elementAt(j).getID();
									name1 = tbList.getTimetableDescriptors().elementAt(j).getName();
									day1 = tbList.getTimetableDescriptors().elementAt(j).getDay();
									month1 = tbList.getTimetableDescriptors().elementAt(j).getMonth();
									year1 = tbList.getTimetableDescriptors().elementAt(j).getYear();
									hour1 = tbList.getTimetableDescriptors().elementAt(j).getHour();
									minute1 = tbList.getTimetableDescriptors().elementAt(j).getMinute();
									recruiter = tbList.getTimetableDescriptors().elementAt(j).getRecruiterName();
									offer = tbList.getTimetableDescriptors().elementAt(j).getOfferName();
									String date1 = "";
									if(minute1 == 0)
									{	
										date1 = month1+"/"+day1+"/"+year1+ " " +hour1+":"+minute1+"0";
									}
									else
									{
										date1 = month1+"/"+day1+"/"+year1+ " " +hour1+":"+minute1;
									}
									//SimpleDateFormat df = new SimpleDateFormat("EEE, d MMM yyyy HH:mm");
									//df.setLenient(false);
									//Date dt1 = df.parse(date1);
									//GregorianCalendar calendar1 = new GregorianCalendar(); 
									//calendar1.setTime(dt1);
									//for(int i=0; i<sizeList; i++)
									//{
										//day2 = tbList.getTimetableDescriptors().elementAt(i).getDay();
										//month2 = tbList.getTimetableDescriptors().elementAt(i).getMonth();
										//year2 = tbList.getTimetableDescriptors().elementAt(i).getYear();
										//hour2 = tbList.getTimetableDescriptors().elementAt(i).getHour();
										//minute2 = tbList.getTimetableDescriptors().elementAt(i).getMinute();
										//String date2 = month2+"/"+day2+"/"+year2+ " " +hour2+":"+minute2;
										//Date dt2 = df.parse(date2);
										//GregorianCalendar calendar2 = new GregorianCalendar(); 
										//calendar2.setTime(dt2);
										//if(calendar1.compareTo(calendar2) == 1 )
										//{
											//tb = tbList2.getTimetableDescriptors().elementAt(j);
										//}
									//}*/
					%>
						<h4><%= date1 %> - <%= name1 %></h4>
						<p> You will meet <%= recruiter %> for the offer: <%= offer %> </p>
						<p><a href="javascript:document.edit<%= j %>.submit();" title="Edit the event: <%= name1 %>">Edit</a> | <a href="javascript:openDeleteWindow(document.getElementById('eventName<%= j %>'),document.delete<%= j %>);" title="Delete the event: <%= name1 %>">Delete</a></p>
						<form name="edit<%= j %>" method="post">
							<input type="hidden" name="action" value="editEvent"> 
							<input type="hidden" name="eventID" value="<%= id %>">    
							<input id="eventName<%= j %>" type="hidden" value="<%= name1 %>">  
						</form>
						<form name="delete<%= j %>" method="post">
							<input type="hidden" name="action" value="deleteEvent"> 
							<input type="hidden" name="eventID" value="<%= id %>">     
						</form> 
						<br>
						<hr>
						<br>
					<% 
									//tbList2.deleteElt(tb);
									//j++;
								}
							}
						}
						else
						{
							if(error1 != null)
							{
					%>
								<p><%= error1 %></p>
								<form name="addEvent" method="post">
									<input type="hidden" name="action" value="addEvents">     
								</form> 
								<a href="javascript:document.addEvent.submit();" title="Add an event">Add an event</a>
					<%
							}
						}
					%>
				</div>
	    	</div>
			<jsp:include page="StudentPageFooter.jsp"></jsp:include>
		</div>
	</body>
</html>